package com.xemotion.weceem.files

import org.weceem.files.WcmContentFile

/**
 * WcmContentFileBin.
 * @author YNote
 *
 * To store and restore binary data of WcmContentFile.
 */
class WcmContentFileBin {
	
    long wcmContentId = 0
    String resourcePath
    String relativePath  // @todo YNote  I plan to cache used well images. I want to use "relativePath" for a servelet for cached images.
    byte[] data
	
    // same WcmContentFile properties
    String fileName
    String fileMimeType
    long fileSize = 0
	
    Date dateCreated

    static constraints = {
        wcmContentId(min:1L)
        data(nullable:false, maxSize:10485760)  // Max file size: 10MB
        resourcePath(blank:false)
        relativePath(blank:false)
        fileName(blank:false)
        fileMimeType(blank:false)
        fileSize()
        dateCreated()
    }
	
    static mapping = {
        wcmContentId index:'wcm_content_file_bin_wcm_content_id_idx'
        resourcePath index:'wcm_content_file_bin_resource_path_idx'
        relativePath index:'wcm_content_file_bin_relative_path_idx'
    }
	
}
